package com.zhangwei.service.impl;


import com.zhangwei.mapper.IsConfigMapper;
import com.zhangwei.pojo.IsConfig;
import com.zhangwei.service.IsConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
public class IsConfigServiceImpl implements IsConfigService {

    @Autowired
    IsConfigMapper isConfigMapper;

    @Override
    public List<IsConfig> selectAll() {

        List<IsConfig> list= isConfigMapper.selectAll();
        return list;
    }

    @Override
    public IsConfig selectById(int id) {
        return isConfigMapper.selectById(id);
    }

    @Override
    public int insertOne(IsConfig isConfig) {
        log.info("执行增加操作");
        return isConfigMapper.insertOne(isConfig);
    }

    @Override
    public int delById(int id) {

        return isConfigMapper.delById(id);
    }

    @Override
    public int updateOne(IsConfig isConfig) {

//        System.out.println("access  update  1111111111");
        System.out.println(isConfig.getId()+isConfig.getCname());
        return isConfigMapper.updateOne(isConfig);
    }

    @Override
    @Transactional
    public int enableOneIs(int id) {

        int a=isConfigMapper.enableOneIs(id);
        int b=isConfigMapper.disableOtherIs(id);
        System.out.println(" 修改配置："+a+b);
        log.info(" 修改配置：{},{}",a,b);
        return a+b;
    }

//    @Override
//    public int disableOtherIs(int id) {
//        return isConfigMapper.disableOtherIs(id);
//    }
}
